/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kamus;

import com.util.CommonUtil;
import java.util.Date;

/**
 *
 * @author omega
 */
public class Test {

    public static String[] getContentGzip(String data) {
        String[] result = new String[2];
        StringBuffer  sb = new StringBuffer(data);
        int idxAwal, idxAkhir;
        for (int i = 0; i < 2; i++) {
            idxAwal = sb.toString().indexOf("<content>");
            idxAkhir = sb.toString().indexOf("</content>");
            result[i]=sb.toString().substring(idxAwal+9, idxAkhir);
            sb.delete(idxAwal, idxAkhir + 10);
        }
        return result;
    }

    public static void main(String[] args) {
        String message = "<xml>"
                + "<code>2</code>"
                + "<msg>Both of databases were updated</msg>"
                + "<db name=\"gi\">"
                + "<content></content>"
                + "<date>1286125200000</date>"
                + "</db>"
                + "<db name=\"ig\">"
                + "<content></content>"
                + "<date>1286384400000</date>"
                + "</db>"
                + "</xml>";
        String [] content = getContentGzip(message);
        for (int i = 0; i < content.length; i++) {
            String string = content[i];
            System.out.println(i+":"+string);
        }

////////////////////Date conversion//////////////////////////////
//        try {
//            SimpleDateFormat sd = new SimpleDateFormat("yyyyMMdd");
//            sd.format(new Date());
//            Date date = sd.parse("20100101");
//            System.out.println("a:" + date.toString());
//            System.out.println("t:" + date.getTime());
//        } catch (ParseException ex) {
//            Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
//        }
    }
}
